<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><%= projectName %></title>
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1, minimum-scale=1,maximum-scale=1"/>
    <style>
        body, canvas, div {
            -moz-user-select: none;
            -webkit-user-select: none;
            -ms-user-select: none;
            -khtml-user-select: none;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        }
    </style>
</head>
<body style="padding: 0; margin: 0; background: #000;">
    <canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
    
    <!-- Configure SystemJS to handle CORS in iframe -->
    <script>
        // Override SystemJS fetch to handle CORS issues in iframe
        if (window.parent !== window) {
            // Wait for SystemJS to be available
            const waitForSystemJS = () => {
                if (typeof System !== 'undefined' && System.constructor && System.constructor.prototype) {
                    const originalFetch = System.constructor.prototype.fetch;
                    System.constructor.prototype.fetch = function(url, options) {
                        // Remove crossOrigin for virtual modules
                        if (url.startsWith('chunks://')) {
                            return originalFetch.call(this, url, { ...options, mode: 'no-cors' });
                        }
                        return originalFetch.call(this, url, options);
                    };
                } else {
                    // Retry after a short delay
                    setTimeout(waitForSystemJS, 10);
                }
            };
            waitForSystemJS();
        }
    </script>
    
    <script src="src/settings.js" charset="utf-8" crossorigin="anonymous"></script>
    
    <script src="src/system.bundle.js" charset="utf-8" crossorigin="anonymous"></script>
    
    <script src="src/import-map.json" charset="utf-8" crossorigin="anonymous"></script>
    
    <script src="src/application.js" charset="utf-8" crossorigin="anonymous"></script>
    
    <script>
        System.import('./index.js').catch(function(err) { console.error(err); })
    </script>
</body>
</html>